package com.DreamTeam.daoProxy;

import java.util.ArrayList;
import java.util.List;

import com.DreamTeam.dao.IUserDao;
import com.DreamTeam.daoImpl.UserDao;
import com.DreamTeam.dbc.MySqlConnection;
import com.DreamTeam.po.User;

public class UserDaoProxy implements IUserDao {
	private MySqlConnection conn;
	private IUserDao userDao;
	public UserDaoProxy(){
		conn = new MySqlConnection();
		userDao = new UserDao(conn.getConnection());
	}
	@Override
	public boolean doAdd(User user) {
		boolean flag = false;
		flag=userDao.doAdd(user);
		conn.closeConnection();
		return flag;
	}
	@Override
	public boolean doUpdate(User user) {
		boolean flag = false;
		flag = userDao.doUpdate(user);
		conn.closeConnection();
		return flag;
	}
	@Override
	public boolean doDelete(User user) {
		boolean flag = false;
		flag = userDao.doDelete(user);
		conn.closeConnection();
		return flag;
	}
	@Override
	public List<User> queryUserByColumn(String keyword,String columnName,String orderColumn,String model) {
		List<User> list;
		list = userDao.queryUserByColumn(keyword, columnName, orderColumn, model);
		conn.closeConnection();
		return list;
	}
	@Override
	public List<User> queryUserAll() {
		List<User> list  = new ArrayList();
		list = userDao.queryUserAll();
		conn.closeConnection();
		return list;
	}
	@Override
	public List<User> queryOrderByColumnName(String columnName,String model) {
		List<User> list = new ArrayList();
		list = userDao.queryOrderByColumnName(columnName,model);
		conn.closeConnection();
		return list;
	}
	@Override
	public User queryUserByUserName(String userName) {
		User user;
		user = userDao.queryUserByUserName(userName);
		conn.closeConnection();
		return user;
	}
	
}
